package com.dailyblue.java.standard.thread.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemoA {
    public static void main(String[] args) {
        // 产生了一个可缓存线程池
        ExecutorService service = Executors.newCachedThreadPool();
        for (int i = 0; i < 100; i++) {
            // 产生了一个任务
            Task t = new Task(i);
            // 这个线程池很灵活
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            service.submit(t);
        }
    }

}
